package com.jprocms.module.cms.convert.content;

import com.jpro.framework.common.pojo.PageResult;
import com.jprocms.module.cms.controller.admin.content.relatevo.ContentRelateCreateReqVO;
import com.jprocms.module.cms.controller.admin.content.relatevo.ContentRelateExcelVO;
import com.jprocms.module.cms.controller.admin.content.relatevo.ContentRelateRespVO;
import com.jprocms.module.cms.controller.admin.content.relatevo.ContentRelateUpdateReqVO;
import com.jprocms.module.cms.dal.dataobject.content.ContentRelateDO;
import org.mapstruct.IterableMapping;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Named;
import org.mapstruct.factory.Mappers;

import java.util.List;

/**
 * 相关内容 Convert
 *
 * @author jprocms
 */
@Mapper
public interface ContentRelateConvert {

    ContentRelateConvert INSTANCE = Mappers.getMapper(ContentRelateConvert.class);

    ContentRelateDO convert(ContentRelateCreateReqVO bean);

    ContentRelateDO convert(ContentRelateUpdateReqVO bean);

    ContentRelateRespVO convert(ContentRelateDO bean);

    @Mapping(source = "relateContent.channelName", target = "channelName")
    @Mapping(source = "relateContent.title", target = "relateTitle")
    @Named(value = "convertMore")
    ContentRelateRespVO convertMore(ContentRelateDO bean);

    @IterableMapping(qualifiedByName = "convertMore")
    List<ContentRelateRespVO> convertList(List<ContentRelateDO> list);

    @IterableMapping(qualifiedByName = "convertMore")
    PageResult<ContentRelateRespVO> convertPage(PageResult<ContentRelateDO> page);

    List<ContentRelateExcelVO> convertList02(List<ContentRelateDO> list);

}
